/**
* Copyright (C) 2008 Happy Fish / YuQing
*
* FastDFS may be copied only under the terms of the GNU General
* Public License V3, which may be found in the FastDFS source kit.
* Please visit the FastDFS Home Page http://www.csource.org/ for more detail.
**/

//fc_types.h

#ifndef _FC_TYPES_H
#define _FC_TYPES_H

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "fc_define.h"

#ifdef __cplusplus
extern "C" {
#endif

#define FC_MAX_TITLE_LEN 255
#define FC_MAX_USER_LEN 255
#define FC_MAX_USER_NICK_LEN 255
#define FC_MAX_AREA_LEN 20
#define FC_MAX_POST_TABLE_LEN 10

typedef struct
{
	unsigned int board_id;
	unsigned int thread_id;				// thread id
	unsigned int post_id;
	int title_len;
	char title[FC_MAX_TITLE_LEN+1];		// post title
	int creator_len;
	char creator[FC_MAX_USER_LEN+1];		// post creator
	int creator_nick_len;
	char creator_nick[FC_MAX_USER_NICK_LEN+1];
	int create_ip;				// post crator ip
	int attach_type;			// post attache type
	int floor;
} FCPostRaw;

typedef struct
{
	unsigned int post_id;				// post id
	int title_len;
	char title[FC_MAX_TITLE_LEN+1];		// post title
	int status;				// post status
	int attach_type;			// post attache type
	int floor;
	int creator_len ;
	char creator[FC_MAX_USER_LEN+1];		// post creator
	int creator_nick_len;
	char creator_nick[FC_MAX_USER_NICK_LEN+1];
	int create_ip;				// post crator ip
	time_t create_time;			// post create time
	time_t mod_time;			// post mod time
	int mod_user_len;
	char mod_user[FC_MAX_USER_LEN+1];		// post creator
	int deleted;
	time_t deleted_time;
	int deleted_user_len;
	char deleted_user[FC_MAX_USER_LEN+1];
} FCPostNode;

typedef struct
{
	unsigned int board_id;				// board id
	unsigned int thread_id;				// thread id
	int title_len;
	char title[FC_MAX_TITLE_LEN+1];		// thread title
	int creator_len;
	char creator[FC_MAX_USER_LEN+1];		// thread creator
	int creator_nick_len;
	char creator_nick[FC_MAX_USER_NICK_LEN+1];
	int create_ip;				// thread crator ip
	int types;				// thread type
	int attach_type;			// thread attache type
	int area_len;
	char area[FC_MAX_AREA_LEN+1];
	int post_node;
	int post_table_len;
	char post_table[FC_MAX_POST_TABLE_LEN+1];
} FCThreadRaw;

typedef struct
{
	unsigned int thread_id;				// thread id
	int title_len;
	char title[FC_MAX_TITLE_LEN+1];		// thread title
	time_t create_time;			// thread create time
	int creator_len;
	char creator[FC_MAX_USER_LEN+1];		// thread creator
	int creator_nick_len;
	char creator_nick[FC_MAX_USER_NICK_LEN+1];		// thread creator_nick
	time_t last_reply_time;			// thread last reply time
	int last_replyer_len;
	char last_replyer[FC_MAX_USER_LEN+1];	// thread last replyer
	int last_replyer_nick_len;
	char last_replyer_nick[FC_MAX_USER_NICK_LEN+1];
	int rating;
	unsigned int reply_count;			// thread reply count
	int types;				// thread types
	int status;				// thread status
	int attach_type;			// thread attache type
	int area_len;
	char area[FC_MAX_AREA_LEN+1];
	int elite;
	int top;
	int post_node;
	int post_table_len;
	char post_table[FC_MAX_POST_TABLE_LEN+1];
	//		int create_ip;				// post crator ip
} FCThreadNode;

typedef struct
{
	int sock;
	int port;
	char ip_addr[IP_ADDRESS_SIZE];
} FCServerInfo;

typedef struct
{
	char ip_addr[IP_ADDRESS_SIZE];
	bool sync_old_done;
	int port;
	int sync_req_count;    //sync req count
	int64_t update_count;  //runtime var
} FCGroupServer;

typedef struct {
	uint64_t total_set_count;
	uint64_t success_set_count;
	uint64_t total_inc_count;
	uint64_t success_inc_count;
	uint64_t total_delete_count;
	uint64_t success_delete_count;
	uint64_t total_get_count;
	uint64_t success_get_count;
} FCServerStat;

typedef struct
{
	FCServerInfo **servers;
	int count;  //server count
} ServerArray;

typedef struct
{
	ServerArray *groups;
	FCServerInfo *servers;
	int group_count;  //group count
	int server_count;
} GroupArray;

typedef struct {
	unsigned int board_id;
	int start;
	int num;
	int sortttype;
}FCGetThreads;

typedef struct {
	unsigned int board_id;
	unsigned int thread_id;
	int num;
	int sortttype;
}FCGetThreadsId;

typedef struct {
	unsigned int board_id;
	unsigned int thread_id;
	int start;
	int num;
}FCGetPosts;

typedef struct {
	unsigned int board_id;
	unsigned int thread_id;
	int status;
}FCModifyThreadStatus;

typedef struct {
	unsigned int board_id;
	unsigned int thread_id;
	int type;
}FCModifyThreadType;

typedef struct {
	unsigned int board_id;
	unsigned int thread_id;
	int attach_type;
}FCModifyThreadAttachType;

typedef struct {
	unsigned int thread_id;
	unsigned int post_id;
	int attach_type;
}FCModifyPostAttachType;

typedef struct {
	unsigned int thread_id;
	unsigned int post_id;
	int status;
}FCModifyPostStatus;

#ifdef __cplusplus
}
#endif

#endif

